/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package warehouse;

import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

/**
 *
 * @author Adriana
 */
public class ChartBars {

    DefaultCategoryDataset ds;
    JFreeChart chart;

    public ChartBars() {
        this.ds = new DefaultCategoryDataset();
        this.chart = null;
    }

    public void addBarsDataSet(String[] label, double[] values) throws IOException {
        for (int i = 0; label[i] != null; i++) {
            ds.addValue(values[i], label[i], "");
        }
    }

    public void addBarEntry(String label, double value) throws IOException {
        ds.addValue(value, label, "");
    }

    public JFreeChart createBarsChart(String title, String xlabel, String ylabel) {

        this.chart = ChartFactory.createBarChart(
                title, xlabel, ylabel, ds, PlotOrientation.VERTICAL, true, false, false);
        return this.chart;

    }
}
